
import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router'
import Layout from '@/layout/index.vue'
import baseStore from "@/store";
const routes: Array<RouteRecordRaw> = [
  {
    path: '/',
    component: Layout,
    redirect:'assetInfo',
    children: [
      {
        path:'assetInfo',
        name:'assetInfo',
        component:() => import('@/views/assetInfo/index.vue'),
        meta: { 
          title: '资产信息',
          headerTitle: '国资平台（新津区）',
          icon: 'tabbar-assetInfo',
          tabbar: true
        }
      },
      {
        path:'manageInfo',
        name:'manageInfo',
        component:() => import('@/views/manageInfo/index.vue'),
        meta: { 
          title: '经营信息',
          headerTitle: '国资平台（新津区）',
          icon: 'tabbar-manageInfo',
          tabbar: true
        }
      },
      {
        path:'projectList',
        name:'projectList',
        component:() => import('@/views/projectList/index.vue'),
        meta: { 
          title: '项目列表',
          headerTitle: '国资平台（新津区）',
          icon: 'tabbar-projectList',
          tabbar: true
        },
      },
      {
        path:'projectInfo',
        name:'projectInfo',
        component:() => import('@/views/projectInfo/index.vue'),
        meta: { 
          headerTitle: '项目A',
          icon: 'tabbar-manageInfo'
        }
      },
      {
        path:'contractDetails',
        name:'contractDetails',
        component:() => import('@/views/contractDetails/index.vue'),
        meta: { 
          headerTitle: '合同明细',
          icon: 'tabbar-manageInfo'
        }
      },
    ],
  },
]

// 创建路由实例并传递 `routes` 配置
const router = createRouter({
  // 4. 内部提供了 history 模式的实现。为了简单起见，我们在这里使用 hash 模式。
  history: createWebHashHistory(),
  routes, 
})

router.beforeEach(async () => {
  let store = baseStore()
  await store.resetToken()
  !store.baseCompany.length && await store.getBaseData()
  return true
})
export default router